<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'news';
$_RQ['op']=$_RQ['onetype']?:$_RQ['op'];
$return=array();
if($_RQ['wechat_id']){
	$_SESSION['wechat_id']=intval($_RQ['wechat_id']);
}
if(!$_SESSION['wechat_id']){
	exi('请先选择公众号！','error');
}
$return['msgtypes']=array('0'=>'文本','1'=>'图片','2'=>'语音','3'=>'视频','4'=>'图文');
$return['onetype']=$_RQ['onetype'];
$return['ismore']=$_RQ['ismore'];
if($_RQ['op']=='image'){
	//图片素材
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	//$params['wxgid']=$_SESSION['wechat_id'];
	$params['type']=1;
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby='id desc';
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$list=pdo_getslice('core_media',$params,array($pindex,$psize),$total,array('id','media_id','title','attachment'),'',$orderby);
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	exi($return);
}
if($_RQ['op']=='voice'){
	//语音素材
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	//$params['wxgid']=$_SESSION['wechat_id'];
	$params['type']=2;
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby='id desc';
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$list=pdo_getslice('core_media',$params,array($pindex,$psize),$total,array('id','attachment','title','media_id'),'id',$orderby);
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	exi($return);
}
if($_RQ['op']=='video'){
	//视频素材
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	//$params['wxgid']=$_SESSION['wechat_id'];
	$params['type']=3;
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby='id desc';
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$list=pdo_getslice('core_media',$params,array($pindex,$psize),$total,array('id','attachment','title','media_id'),'id',$orderby);
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	exi($return);
}
if($_RQ['op']=='news'){
	//图文素材
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	//$params['wxgid']=$_SESSION['wechat_id'];
	$params['type']=4;
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby='id desc';
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$list=pdo_getslice('core_media',$params,array($pindex,$psize),$total,array('id','attachment','title','media_id'),'id',$orderby);
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	exi($return);
}

